<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <!-- header -->
    <%@ include file="/WEB-INF/views/include/header.jsp" %>
</head>
<body class="no-skin">
<!-- /section:basics/navbar.layout -->
<div class="main-container" id="main-container">

    <!-- /section:basics/sidebar -->
    <div class="main-content">
        <div class="main-content-inner">
            <div class="page-content">
                <!-- /section:settings.box -->
                <div class="row">
                    <div class="col-xs-12">
                        <!-- PAGE CONTENT BEGINS -->
                        <!-- jqGrid表格 -->
                        <table id="gridTable"></table>
                        <!-- jqGrid工具类 -->
                        <div id="gridPager"></div>
                        <!-- 查询对话框 -->
                        <div style="display: none;">
                            <div class="row" id="queryDialog"></div>
                        </div>
                        <!-- PAGE CONTENT ENDS -->
                    </div><!-- /.col -->
                </div><!-- /.row -->
            </div><!-- /.page-content -->
        </div>
    </div><!-- /.main-content -->

    <a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
        <i class="ace-icon fa fa-angle-double-up icon-only bigger-110"></i>
    </a>

    <%@ include file="/WEB-INF/views/include/dialog.jsp" %>
</div><!-- /.main-container -->
</div>

<!-- footer -->
<%@ include file="/WEB-INF/views/include/footer.jsp" %>

<script type="text/javascript">
    // 基本路径
    var baseUrl = "<s:url value="/taskMain/deleteTask/"></s:url>"

    // jqgrid的表格高度
    var height = 320;
    // jqgrid表格行头的中文
    var colNames = ['', '任务名称', "事项类型", "状态","办理时限","逾期说明", "状态说明","操作"];


    var colModel = [
        {name: 'sysId', width: 60, hidden: true, key: true},
        {name: 'mainName', index: 'mainName', width: 250, editable: true},
        {name: 'categoryId', index: 'categoryId', width: 250, editable: true, formatter: categoryIdFormatter},
        {name: 'status', index: 'status', width: 150, editable: true, formatter: typeFormatter},
        {name: 'timeLimit', index: 'timeLimit', width: 150, editable: true},
        {name: 'typeExplain', index: 'typeExplain', width: 350, editable: true },
        {name: 'overdueExplain', index: 'overdueExplain', width: 250, editable: true},
        {name : 'sy', width : 250, align : "center",formatter:feedbackBtnFormatter }
    ];

    /**
     * 任务类型格式化
     */
    function categoryIdFormatter(data) {
        let mz = '';
        $.ajax({
            url:"/taskMain/categoryName/"+data,
            type:"get",
            dataType:'json',
            async:false,
            success:function (data) {
                mz = data.category;
            }
        })
        return mz;
    }

    /**
     * 任务状态格式化
     */
    function typeFormatter(data) {
        switch(data) {
            case '0':
                return '待审批';
                break;
            case '1':
                return '审批未通过';
                break;
            case '2':
                return '正常';
                break;
            case '3':
                return '新反馈';
            case '4':
                return '已完成';
            case '5':
                return '退回重办';
            case '9':
                return '待立项';
            default:
                return '未知';
        }
    }


    function feedbackBtnFormatter(value, grid, rows, state) {
        console.log(value, grid, rows, state);
        grid.colModel.title=false
        return "<div style='color: #049CE6;display: flex;justify-content: center'>" +
            "<div style='width: 40px;cursor: pointer' title='恢复'id='recovery'>恢复</div>" +
            "</div>";
    }

    var rowIds;
    // jqgrid的具体执行方法
    jqgrid({
        gridTableId: "#gridTable",
        gridPagerId: "#gridPager",
        autoScroll: false,
        shrinkToFit: false,
        multiselect:false,
        rownumbers: true,
        onSelectRow: function (rowid, status) {
            //选择当前的行
            rowIds = rowid;
            var selectedRowValue = $("#gridTable").jqGrid('getRowData', rowid);
         },
    });

    //清空选中行
    $("#cancelChecked").click(function () {
        $("#gridTable").jqGrid('resetSelection');
    });
    var rowids = [];//选中行id
    /**
     * 取消选中
     */
    function gridRemoveSelect(rowid) {
        rowids.remove(rowid);
    }

    $(document).on("click","#recovery",function () {
        $.get("/taskMain/recover/"+rowIds,function (data) {
                alert(data.message);
                setTimeout(function () {
                    open(location, '_self').close();
                },50)
        })
    })
















</script>

</body>
</html>